
use "$path\Intermediary Data\base_suff_stat_6Y"
keep id freq mean meanp meann sd skewness kurtosis k_15 lt_effect CIR_2 auto

order freq mean meanp meann sd skewness kurtosis k_15 lt_effect CIR_2 auto
sum freq mean meanp meann sd skewness kurtosis k_15 lt_effect CIR_2 auto, d

sum sd

/* Col 1: mean */
capture drop col1
gen col1=.
forvalues i=1/11 {
if `i'==1  {
sum freq, d
}
else if `i'==2 {
sum mean, d
}
else if  `i'==3 {
sum meanp, d
}
else if  `i'==4 {
sum meann, d
}
else if  `i'==5 {
sum sd, d
} 
else if  `i'==6 {
sum skewness, d
} 
else if  `i'==7 {
sum kurtosis, d
} 
else if  `i'==8 {
sum k_15, d
} 
else if  `i'==9 {
sum auto, d
} 
else if  `i'==10 {
sum lt_effect, d
} 
else if  `i'==11 {
sum CIR_2, d
} 
replace col1=r(mean) if _n==1 & `i'==1 
replace col1=r(mean)*100 if _n==2 & `i'==2
replace col1=r(mean)*100 if _n==3 & `i'==3
replace col1=r(mean)*(-100) if _n==4 & `i'==4
replace col1=r(mean)*100 if _n==5 & `i'==5
replace col1=r(mean) if _n==6 & `i'==6
replace col1=r(mean) if _n==7 & `i'==7
replace col1=r(mean) if _n==8 & `i'==8
replace col1=r(mean) if _n==9 & `i'==9
replace col1=r(mean) if _n==10 & `i'==10
replace col1=r(mean) if _n==11 & `i'==11

}




/* Col 2: p10 */
capture drop col2
gen col2=.
forvalues i=1/11 {
if `i'==1  {
sum freq, d
}
else if `i'==2 {
sum mean, d
}
else if  `i'==3 {
sum meanp, d
}
else if  `i'==4 {
sum meann, d
}
else if  `i'==5 {
sum sd, d
} 
else if  `i'==6 {
sum skewness, d
} 
else if  `i'==7 {
sum kurtosis, d
} 
else if  `i'==8 {
sum k_15, d
} 
else if  `i'==9 {
sum auto, d
} 
else if  `i'==10 {
sum lt_effect, d
} 
else if  `i'==11 {
sum CIR_2, d
} 
replace col2=r(p10) if _n==1 & `i'==1 
replace col2=r(p10)*100 if _n==2 & `i'==2
replace col2=r(p10)*100 if _n==3 & `i'==3
replace col2=r(p10)*(-100) if _n==4 & `i'==4
replace col2=r(p10)*100 if _n==5 & `i'==5
replace col2=r(p10) if _n==6 & `i'==6
replace col2=r(p10) if _n==7 & `i'==7
replace col2=r(p10) if _n==8 & `i'==8
replace col2=r(p10) if _n==9 & `i'==9
replace col2=r(p10) if _n==10 & `i'==10
replace col2=r(p10) if _n==11 & `i'==11
}



/* Col 3: p25 */
capture drop col3
gen col3=.
forvalues i=1/11 {
if `i'==1  {
sum freq, d
}
else if `i'==2 {
sum mean, d
}
else if  `i'==3 {
sum meanp, d
}
else if  `i'==4 {
sum meann, d
}
else if  `i'==5 {
sum sd, d
} 
else if  `i'==6 {
sum skewness, d
} 
else if  `i'==7 {
sum kurtosis, d
} 
else if  `i'==8 {
sum k_15, d
} 
else if  `i'==9 {
sum auto, d
} 
else if  `i'==10 {
sum lt_effect, d
} 
else if  `i'==11 {
sum CIR_2, d
} 
replace col3=r(p25) if _n==1 & `i'==1 
replace col3=r(p25)*100 if _n==2 & `i'==2
replace col3=r(p25)*100 if _n==3 & `i'==3
replace col3=r(p25)*(-100) if _n==4 & `i'==4
replace col3=r(p25)*100 if _n==5 & `i'==5
replace col3=r(p25) if _n==6 & `i'==6
replace col3=r(p25) if _n==7 & `i'==7
replace col3=r(p25) if _n==8 & `i'==8
replace col3=r(p25) if _n==9 & `i'==9
replace col3=r(p25) if _n==10 & `i'==10
replace col3=r(p25) if _n==11 & `i'==11
}

/* Col 4: p50 */
capture drop col4
gen col4=.
forvalues i=1/11 {
if `i'==1  {
sum freq, d
}
else if `i'==2 {
sum mean, d
}
else if  `i'==3 {
sum meanp, d
}
else if  `i'==4 {
sum meann, d
}
else if  `i'==5 {
sum sd, d
} 
else if  `i'==6 {
sum skewness, d
} 
else if  `i'==7 {
sum kurtosis, d
} 
else if  `i'==8 {
sum k_15, d
} 
else if  `i'==9 {
sum auto, d
} 
else if  `i'==10 {
sum lt_effect, d
} 
else if  `i'==11 {
sum CIR_2, d
} 
replace col4=r(p50) if _n==1 & `i'==1 
replace col4=r(p50)*100 if _n==2 & `i'==2
replace col4=r(p50)*100 if _n==3 & `i'==3
replace col4=r(p50)*(-100) if _n==4 & `i'==4
replace col4=r(p50)*100 if _n==5 & `i'==5
replace col4=r(p50) if _n==6 & `i'==6
replace col4=r(p50) if _n==7 & `i'==7
replace col4=r(p50) if _n==8 & `i'==8
replace col4=r(p50) if _n==9 & `i'==9
replace col4=r(p50) if _n==10 & `i'==10
replace col4=r(p50) if _n==11 & `i'==11
}


/* Col 5: p75 */
capture drop col5
gen col5=.
forvalues i=1/11 {
if `i'==1  {
sum freq, d
}
else if `i'==2 {
sum mean, d
}
else if  `i'==3 {
sum meanp, d
}
else if  `i'==4 {
sum meann, d
}
else if  `i'==5 {
sum sd, d
} 
else if  `i'==6 {
sum skewness, d
} 
else if  `i'==7 {
sum kurtosis, d
} 
else if  `i'==8 {
sum k_15, d
} 
else if  `i'==9 {
sum auto, d
} 
else if  `i'==10 {
sum lt_effect, d
} 
else if  `i'==11 {
sum CIR_2, d
} 
replace col5=r(p75) if _n==1 & `i'==1 
replace col5=r(p75)*100 if _n==2 & `i'==2
replace col5=r(p75)*100 if _n==3 & `i'==3
replace col5=r(p75)*(-100) if _n==4 & `i'==4
replace col5=r(p75)*100 if _n==5 & `i'==5
replace col5=r(p75) if _n==6 & `i'==6
replace col5=r(p75) if _n==7 & `i'==7
replace col5=r(p75) if _n==8 & `i'==8
replace col5=r(p75) if _n==9 & `i'==9
replace col5=r(p75) if _n==10 & `i'==10
replace col5=r(p75) if _n==11 & `i'==11
}



/* Col 6: p90 */
capture drop col6
gen col6=.
forvalues i=1/11 {
if `i'==1  {
sum freq, d
}
else if `i'==2 {
sum mean, d
}
else if  `i'==3 {
sum meanp, d
}
else if  `i'==4 {
sum meann, d
}
else if  `i'==5 {
sum sd, d
} 
else if  `i'==6 {
sum skewness, d
} 
else if  `i'==7 {
sum kurtosis, d
} 
else if  `i'==8 {
sum k_15, d
} 
else if  `i'==9 {
sum auto, d
} 
else if  `i'==10 {
sum lt_effect, d
} 
else if  `i'==11 {
sum CIR_2, d
} 
replace col6=r(p90) if _n==1 & `i'==1 
replace col6=r(p90)*100 if _n==2 & `i'==2
replace col6=r(p90)*100 if _n==3 & `i'==3
replace col6=r(p90)*(-100) if _n==4 & `i'==4
replace col6=r(p90)*100 if _n==5 & `i'==5
replace col6=r(p90) if _n==6 & `i'==6
replace col6=r(p90) if _n==7 & `i'==7
replace col6=r(p90) if _n==8 & `i'==8
replace col6=r(p90) if _n==9 & `i'==9
replace col6=r(p90) if _n==10 & `i'==10
replace col6=r(p90) if _n==11 & `i'==11
}


keep col*
rename col1 Average
rename col2 P10
rename col3 P25
rename col4 P50
rename col5 P75
rename col6 P90

gen Var="Frequency of price changes" if _n==1
replace Var="Average of price changes (in %)" if _n==2
replace Var="Average of price increases (in %)" if _n==3
replace Var="Average of price decreases (in % - absolute values)" if _n==4
replace Var="Standard Deviation (in %)" if _n==5
replace Var="Skewness" if _n==6
replace Var="Kurtosis" if _n==7
replace Var="Kurtosis incl. correction (15 lags)" if _n==8
replace Var="Autocorrelation of price changes (order 1)" if _n==9
replace Var="Long term pass through (31-36 days)" if _n==10
replace Var="Cumulated price response" if _n==11

drop if _n>11
order Var Average P10 P25 P50 P75 P90

replace Average=round(Average, 0.01)
replace P10=round(P10, 0.01)
replace P25=round(P25, 0.01)
replace P50=round(P50, 0.01)
replace P75=round(P75, 0.01)
replace P90=round(P90, 0.01)

format %9.2f Average P10 P25 P50 P75 P90
save "$path\Graphs_Tables\Table1_Edited.dta", replace

